 <template>
  <div>
    <el-card class="box-card">
      <div slot="header" class="clearFix">
        <h2>业务联系人</h2>
      </div>

      <div>
        <el-form ref="formData" :model="formData" label-width="200px">
          <el-form-item label="是否公开">
            <el-switch v-model="formData.contactsIsPublic" active-color="#13ce66"></el-switch>
          </el-form-item>

          <el-form-item label="联系人姓名">
            <el-input class="input-width" placeholder="联系人姓名" v-model="formData.contactsName"></el-input>
          </el-form-item>

          <el-form-item label="手机号码">
            <div>
              <el-input
                class="input-item input-width"
                v-model="formData.contactsPhone"
                placeholder="手机号码"
              ></el-input>
            </div>
          </el-form-item>

          <el-form-item label="座机号码">
            <div>
              <el-input
                class="input-item input-width"
                v-model="formData.contactsCellPhone"
                placeholder="座机号码"
              ></el-input>
            </div>
          </el-form-item>
          <el-form-item label="QQ账号">
            <div>
              <el-input
                class="input-item input-width"
                v-model="formData.contactsQq"
                placeholder="QQ账号"
              ></el-input>
            </div>
          </el-form-item>

          <el-form-item label="微信账户">
            <div>
              <el-input
                class="input-item input-width"
                v-model="formData.contactsWechat"
                placeholder="微信账户"
              ></el-input>
            </div>
          </el-form-item>

          <el-form-item>
            <!-- <el-button @click="resetForm('formData')" class="widthBtn">重置</el-button> -->
            <el-button class="widthBtn add-style" type="primary" @click="submitForm">提交</el-button>
          </el-form-item>
        </el-form>
      </div>
    </el-card>
  </div>
</template>

<script>
import { setBusiness } from "api/profile";

export default {
  data() {
    return {
      formData: {
        contactsCellPhone: "", //座机号码
        contactsIsPublic: true, //  是否公开
        contactsName: "", // 联系人姓名
        contactsPhone: "", // 手机号码
        contactsPhoneSubsn: "",
        contactsQq: "", //QQ账号
        contactsWechat: "" //微信账户
      }
    };
  },
  props: {
    enterpriceInfo: {
      type: Object,
      default() {
        return [];
      }
    }
  },
  watch: {
    enterpriceInfo: {
      handler: function(newVal, oldVal) {
        this.enterpriceInfo = newVal;
        this.dataInit();
      },
      deep: true
    }
  },
  components: {},
  mounted() {},
  methods: {
    dataInit() {
      for (var i in this.formData) {
        for (var enterItem in this.enterpriceInfo) {
          if (i === enterItem) {
            this.formData[i] = this.enterpriceInfo[enterItem];
          }
        }
      }
    },
    submitForm() {
      setBusiness(this.formData).then(res => {
        this.$message.success("修改成功");
      });
    }
  }
};
</script>

<style lang="scss" scoped>
@import "src/style/mixin";
.longTerm-style {
  color: #888;
  padding: 10px;
}

.form-style {
  width: 600px;
}

.input-item {
  margin-bottom: 20px;
}

.input-width {
  width: 400px;
}
.widthBtn {
  // width: 200px;
  margin: 20px 200px 0 0;
}
</style>
